package cn.fan.whale.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.fan.whale.entity.dto.BaseReturnDto;
import cn.fan.whale.service.SystemService;
import com.alibaba.fastjson2.JSONObject;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.UnknownHostException;

@RestController
@RequestMapping("/system")
@CrossOrigin
@SaCheckLogin
public class SystemController {

    private final SystemService systemService;

    public SystemController(SystemService systemService) {
        this.systemService = systemService;
    }

    @GetMapping("/info")
    public BaseReturnDto info() throws UnknownHostException {
        // {service: {}, jvm: {}}
        JSONObject result = systemService.getServerInfo();
        return BaseReturnDto.success(result);
    }
}
